package javabase.schoolwork.day6_19;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author fance
 * @date 2018/6/19 23:35
 */
public class AsyClient {
    public static void main(String[] args) throws IOException {
        Socket client = new Socket("localhost", 8888);

        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
                client.getOutputStream()));
        final Scanner sc = new Scanner(System.in);

        new Thread(() -> {
            while (true) {
                try {
                    bw.write(sc.nextLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
